<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>Dashboard Template for Bootstrap</title>
        <title>Dashboard Template for Bootstrap</title>
        <!-- Bootstrap core CSS -->
        <link href="../../static/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.min.css}" rel="stylesheet">

        <!-- Custom styles for this template -->
        <link href="../../static/css/dashboard.css" th:href="@{/css/dashboard.css}" rel="stylesheet">
        <style type="text/css">
            /* Chart.js */

            @-webkit-keyframes chartjs-render-animation {
                from {
                    opacity: 0.99
                }
                to {
                    opacity: 1
                }
            }

            @keyframes chartjs-render-animation {
                from {
                    opacity: 0.99
                }
                to {
                    opacity: 1
                }
            }

            .chartjs-render-monitor {
                -webkit-animation: chartjs-render-animation 0.001s;
                animation: chartjs-render-animation 0.001s;
            }
        </style>
    </head>

    <body>
        <!--插入公共topbar-->
        <div th:replace="~{common/topbar :: topbar}"></div>

        <div class="container-fluid">
            <div class="row">
                <!--插入公共navigation-->
                <div th:replace="~{common/navigation :: navigation('emps')}"></div>

                <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
                    <h1><a class="btn btn-sm btn-success" th:href="@{/emp}">添加员工</a></h1>
                    <div class="table-responsive">
                        <table class="table table-striped table-sm" style="text-align: center">
                            <thead>
                            <tr>
                                <th><input type="checkbox"></th>
                                <th>id</th>
                                <th>last name</th>
                                <th>email</th>
                                <th>gender</th>
                                <th>department</th>
                                <th>birthday</th>
                                <th>operation</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="emp:${emps}">
                                <td><input type="checkbox"></td>
                                <td th:text="${emp.id}"></td>
                                <td>[[${emp.lastName}]]</td>
                                <td th:text="${emp.email}"></td>
                                <td th:text="${emp.gender == 1? '男':'女'}"></td>
                                <td th:text="${emp.department.departmentName}"></td>
                                <td th:text="${#dates.format(emp.birth,'yyyy-MM-dd HH:mm:SS')}"></td>
                                <td>
                                    <div class="btn-group">
                                        <!--使用restful风格的url传id到前端页面进行数据的修改和删除-->
                                        <!--使用不同的HTTP请求来区分两种操作：修改使用PUT，删除使用DELETE-->
                                        <a class="btn btn-sm btn-primary" th:href="@{'/emp/' + ${emp.id}}">编辑</a>
                                        <button class="btn btn-sm btn-danger btn-delete" th:attr="del_url=@{'/emp/'+ ${emp.id}}">删除</button>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </main>
                <!--用于提交删除请求-->
                <form  id="form-del" method="post">
                    <input type="hidden" name="_method" value="delete"/>
                </form>
            </div>
        </div>

        <!-- Bootstrap core JavaScript
    ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script type="text/javascript" src="../../static/js/jquery-3.2.1.slim.min.js" th:src="@{/js/jquery-3.2.1.slim.min.js}"></script>
        <script type="text/javascript" src="../../static/js/popper.min.js" th:src="@{/js/popper.min.js}"></script>
        <script type="text/javascript" src="../../static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>

        <!-- Icons -->
        <script type="text/javascript" src="../../static/js/feather.min.js" th:src="@{/js/feather.min.js}"></script>
        <script>
            feather.replace()
        </script>

        <!-- Graphs -->
        <script type="text/javascript" src="../../static/js/Chart.min.js" th:src="@{/js/Chart.min.js}"></script>

        <script>
            $('.btn-delete').click(function () {
                $('#form-del').attr('action', $(this).attr('del_url')).submit();
                return false;
            });
        </script>
    </body>

</html>